package com.lixinyue.test08;

/**
 * @program: 11.12
 * @description:
 * @author: 李鑫月
 * @create: 2021-11-16 20:15
 **/
class Animal{
    protected String name;

    public Animal(String name) {
        this.name = name;
    }
}


interface IFlying{
    void fly();
}
class Bird extends Animal implements IFlying{
    public Bird(String name){
        super(name);
    }
    @Override
    public void fly() {
        System.out.println(this.name+" is flying ");
    }
}
interface IRunning{
    void running();
}
interface ISwimming{
    void swimming();
}
class Frog extends Animal implements IRunning,ISwimming{
    public Frog(String name) {
        super(name);
    }
    public void running(){
        System.out.println(this.name+" is running");
    }
    public void swimming(){
        System.out.println(this.name+" is swimming");
    }
}
class Duck extends Animal implements ISwimming,IRunning,IFlying{
    public Duck(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(this.name+" is flying ");

    }

    @Override
    public void running() {
        System.out.println(this.name+" is running");

    }

    @Override
    public void swimming() {
        System.out.println(this.name+" is swimming");

    }
}
public class Test4 {
    public static void runFunc(IRunning iRunning){
        iRunning.running();
    }
    public static void SwimFunc(ISwimming iSwimming){
       iSwimming.swimming();
    }
    public static void main(String[] args) {
        Duck duck=new Duck("lixr");
        runFunc(duck);
        SwimFunc(duck);
        IFlying flying=new Bird("xiaonaio");
        flying.fly();
    }
}
